package gold.contest;

import gold.utils.InputUtil;

import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.TreeMap;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC5989 {
    public long startExecuteTime = System.currentTimeMillis();


        class Solution {
            public int countElements(int[] nums) {
                TreeMap<Integer, Integer> mp = new TreeMap<>();
                for (int i = 0; i < nums.length; i++) {
                    mp.put(nums[i], mp.getOrDefault(nums[i], 0) + 1);
                }
                int cnt = 0;
                for (Integer key : mp.keySet()) {
                    if (key == mp.firstKey() || key == mp.lastKey()) continue;
                    cnt += mp.get(key);
                }

                return cnt;
            }
        }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.countElements(InputUtil.toIntegerArray("[11,7,2,15]")));
        System.out.println(solution.countElements(InputUtil.toIntegerArray("[-3,3,3,90]")));
    }

    public static void main(String[] args) throws Exception {
        LC5989 an = new LC5989();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
